#include<bits/stdc++.h>
using namespace std;
const int N=1005,mod=1e9+7;
int n,k,w[N];
char s[N],A[N],B[N],S[N];
struct dp{
	int res,cnt;
	inline dp operator+(dp v){return (dp){(res+v.res)%mod,(cnt+v.cnt)%mod};}
}f[N][N][2];
dp F(int i,int j,bool o,bool up){
	if(!up&&~f[i][j][o].res) return f[i][j][o];
	if(i==n+1) return (dp){0,j==k};
	dp ans={0,0};
	for(int c=0;c<=1&&j+c<=k;++c){
		int d=(s[i]=='R')^c^o;
		if(up&&d>S[i]-'0') continue;
		dp v=F(i+1,j+c,o^c,up&&d==S[i]-'0');
		ans=ans+v;
		if(d) (ans.res+=1ll*w[n-i]*v.cnt%mod)%=mod;
	}
	if(!up) f[i][j][o]=ans;
	return ans;
}
inline int st(char *st){
	for(int i=1;i<=n;++i) S[i]=st[i];
	dp ans=F(2,0,0,1)+F(2,0,1,1);
	return (ans.res+1ll*w[n-1]*ans.cnt%mod)%mod;
}
char sb[N];
int main(){
	freopen("lost.in","r",stdin);
	freopen("lost.out","w",stdout);
	scanf("%d%d",&n,&k);
	if(n==1) return cout<<(k==0),0;
	scanf("%s",s+2);
	scanf("%s",A+1);
	scanf("%s",B+1);
	memset(f,-1,sizeof(f));
	w[0]=1;
	for(int i=1;i<=n;++i) w[i]=w[i-1]*2%mod;
	int ans=(st(B)-st(A)+mod)%mod;
	for(int i=1;i<=n;++i) if(A[i]=='1') (ans+=w[n-i])%=mod;
	cout<<ans<<'\n';
	return 0;
}


